home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / khexedit / charcolumninterface.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.5 KB  |  106 lines

  1. /***************************************************************************
  2.                           charcolumninterface.h  -  description
  3.                              -------------------
  4.     begin                : Fri Sep 12 2003
  5.     copyright            : (C) 2003 by Friedrich W. H. Kossebau
  6.     email                : Friedrich.W.H@Kossebau.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This library is free software; you can redistribute it and/or         *
  12.  *   modify it under the terms of the GNU Library General Public           *
  13.  *   License version 2 as published by the Free Software Foundation.       *
  14.  *                                                                         *
  15.  ***************************************************************************/
  16.  
  17.  
  18. #ifndef CHARCOLUMNINTERFACE_H
  19. #define CHARCOLUMNINTERFACE_H
  20.  
  21. #include <qstring.h>
  22.  
  23. namespace KHE
  24. {
  25.  
  26. /**
  27.  * @short A simple interface for the access to the char column of a hex edit widget
  28.  *
  29.  * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  30.  * @see createBytesEditWidget(), charColumnInterface()
  31.  * @since 3.2
  32.  */
  33. class CharColumnInterface
  34. {
  35.   public:
  36.     /** encoding used to display the symbols in the text column */
  37.     enum KEncoding
  38.     {
  39.       /** the encoding of your shell. If that is a multibyte encoding this will default to Latin1. */
  40.       LocalEncoding=0,
  41.       /** extended ASCII encoding, also known as Latin1 */
  42.       ISO8859_1Encoding=1,
  43.       /** @internal not implemented: the most common EBCDIC codepage */
  44.       CECP1047Encoding=2,
  45.       /** @internal enables extension without breaking binary compatibility */
  46.       MaxEncodingId=0xFFFF
  47.     };
  48.  
  49.   public: // set methods
  50.     /** sets whether "unprintable" chars (value<32) should be displayed in the text column
  51.       * with their corresponding character.
  52.       * Default is @c false.
  53.       * @param SU
  54.       * @see showUnprintable()
  55.       */
  56.     virtual void setShowUnprintable( bool SU = true ) = 0;
  57.     /** sets the substitute character for "unprintable" chars
  58.       * Default is '.'.
  59.       * @param SC new character
  60.       * @see substituteChar()
  61.       */
  62.     virtual void setSubstituteChar( QChar SC ) = 0;
  63.     /** sets the encoding of the text column.
  64.       * If the encoding is not available the format will not be changed.
  65.       * Default is @c LocalEncoding.
  66.       * @param C the new encoding
  67.       * @see encoding()
  68.       */
  69.     virtual void setEncoding( KEncoding C ) = 0;
  70.  
  71.  
  72.   public: // get methods
  73.     /** @return @c true if "unprintable" chars (value<32) are displayed in the text column
  74.       * with their corresponding character, @c false otherwise
  75.       * @see setShowUnprintable()
  76.       */
  77.     virtual bool showUnprintable() const = 0;
  78.     /** @return the currently used substitute character for "unprintable" chars.
  79.       * @see setSubstituteChar()
  80.       */
  81.     virtual QChar substituteChar() const = 0;
  82.     /** @return the currently used encoding
  83.       * @see setEncoding()
  84.       */
  85.     virtual KEncoding encoding()   const = 0;
  86. };
  87.  
  88.  
  89. /** tries to get the charcolumn interface of t
  90.   * @return a pointer to the interface, otherwise 0
  91.   * @author Friedrich W. H. Kossebau <Friedrich.W.H@Kossebau.de>
  92.   * @since 3.2
  93.   */
  94. template<class T>
  95. CharColumnInterface *charColumnInterface( T *t )
  96. {
  97.   if( !t )
  98.     return 0;
  99.  
  100.   return static_cast<CharColumnInterface*>( t->qt_cast("KHE::CharColumnInterface") );
  101. }
  102.  
  103. }
  104.  
  105. #endif
  106.